<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
<head>
	<!DOCTYPE html>
<html class="no-js">
<head>
	<meta name="author" content="蓝凌科技">
	<meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
	<meta name="renderer" content="webkit"/>
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link href="/Public/Blovex4/css/amazeui.css" rel="stylesheet">
	<link href="/Public/Blovex4/css/amaze.css" rel="stylesheet">
	<link href="/Public/Blovex4/css/admin.css" rel="stylesheet">
	<link href="/Public/Blovex4/css/jquery.datetimepicker.css" rel="stylesheet">
	<link href="/Public/Blovex4/css/custom.css" rel="stylesheet">
	<link href="/Public/Common/css/amazeui.datetimepicker.css" rel="stylesheet">
	<title><?php echo C('WEB_SITE_TITLE');?></title>
	
	<script type="text/javascript">
	    var _root = '<?php echo ($_site_url); echo U(' / ');?>', _controller = '<?php echo ($_controller); ?>';
	</script>
	
	
	

	<!-- 页面header钩子，一般用于加载插件CSS文件和代码 -->


</head>
<body  style="overflow:hidden;">
	<!-- 头部 -->
	<!-- 导航条
================================================== -->
<header id="amz-header" class="am-topbar am-topbar-fixed-top" >
    <div class="am-g">
        <div class="col-md-2 am-u-md-2">
            <h1>
            	<a href="#" target="_blank">帮工小哥</a>
            	<span class="am-badge am-badge-danger"><?php echo (C("APP_VERSION")); ?></span>
            </h1>
        <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#topbar-collapse'}">
            <span class="am-sr-only">导航切换</span>
            <span class="am-icon-bars"></span>
        </button>
		</div>
        
        <div class="col-md-10 am-u-md-10">
           
            <div class="am-collapse am-topbar-collapse" id="topbar-collapse">
            	<ul class="amz-header-nav am-topbar-nav">
                    <?php if(is_array($__MENU__['main_menu'])): foreach($__MENU__['main_menu'] as $key=>$vo): ?><li>
                            <a href="<?php echo (U($vo["menu_url"])); ?>" style="outline:none;"><?php echo ($vo["menu_name"]); ?></a>
                        </li><?php endforeach; endif; ?>
                   
                </ul>
                <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">
                    <li>
                        <a href="<?php echo U('Public/logout');?>"><span class="am-icon-sign-out" style="color:white;">注销</span></a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</header>


	<style type="text/css">
		ul li{
			
			list-style:none;
		}
	</style>
	

	<!-- /头部 -->
	
	<!-- 主体 -->
	<div class="am-cf am-g">
    <!--左边开始---->
    <div class="am-u-sm-2 am-u-md-2 am-u-lg-2 admin-sidebar am-offcanvas am-offcanvas-style" id="admin-offcanvas">
        <div class="am-offcanvas-bar admin-offcanvas-bar left-style" >
   
	<div class="am-g admin-style">
        <div class="am-u-sm-4">
            <a href="#" class="am-icon-btn am-secondary  am-icon-drupal"></a>
        </div>
        <div class="am-u-sm-8">
            <?php echo ($ADMIN_NAME); ?>
            <br/>
            <a style="cursor:pointer;" title="退出" href="<?php echo U('Public/logout');?>"><span class="am-icon-power-off"></span></a>
            &nbsp; <a style="cursor:pointer;" title="修改密码" href="<?php echo U('Index/updatePassword');?>"><span class="am-icon-lock"></span></a>
        </div>
    </div>
    <ul class="am-list" >
        <?php if(is_array($__MENU__['_child'])): foreach($__MENU__['_child'] as $key=>$sub_menu): if(!empty($sub_menu)): ?><li>
            <a href="<?php echo (U($sub_menu["menu_url"])); ?>"><span class="<?php echo ((isset($sub_menu["menu_icon"]) && ($sub_menu["menu_icon"] !== ""))?($sub_menu["menu_icon"]):''); ?>">&nbsp;</span><?php echo ($sub_menu["menu_name"]); ?><span class="<?php echo ((isset($sub_menu["menu_style"]) && ($sub_menu["menu_style"] !== ""))?($sub_menu["menu_style"]):''); ?>"></span></a>
            <?php if(is_array($sub_menu['_child'])): foreach($sub_menu['_child'] as $key=>$menuname): ?><li class="am-margin-horizontal">
                    <a href="<?php echo (U($menuname["menu_url"])); ?>"><span class="<?php echo ((isset($menuname["menu_icon"]) && ($menuname["menu_icon"] !== ""))?($menuname["menu_icon"]):''); ?>">&nbsp;</span><?php echo ($menuname["menu_name"]); ?><span class="<?php echo ((isset($menuname["menu_style"]) && ($menuname["menu_style"] !== ""))?($menuname["menu_style"]):''); ?>"></span></a>
                </li><?php endforeach; endif; endif; ?>
        </li><?php endforeach; endif; ?>
    </ul>
</div>

    </div><!--左边结束---->
    <div class="am-u-sm-10 am-u-md-10 am-u-lg-10 custom-left am-fr" id="Contename"   >
        <div id="top-alert" class="fixed alert alert-error am-u-sm-12 am-u-md-12" style="display:none">
            <button class="close fixed" style="margin-top: 4px;">
                &times;
            </button>
            <div class="alert-content">
                这是内容
            </div>
        </div>
        
    <div class="am-cf am-padding-top">
        <div class="am-fl am-cf">
            <i class="am-icon-file"></i>
            <strong class="am-text-primary am-text-lg">数据库备份</strong>
        </div>
        <div class="am-text-right am-padding-right">
            <a class="am-btn am-btn-success am-btn-sm" href="javascript:;" autocomplete="off" id="export">备份表</a>
            <a class="am-btn am-btn-secondary am-btn-sm" href="<?php echo U('optimize');?>" id="optimize">优化表</a>
            <a class="am-btn am-btn-warning am-btn-sm" href="<?php echo U('repair');?>" id="repair">修复表</a>
        </div>
        <hr data-am-widget="divider" class="am-divider am-divider-default" />
    </div>
    <form id="export-form" method="post" action="<?php echo U('export');?>" class="am-form">
        <table class="am-table am-table-striped am-table-hover table-main">
            <thead>
                <tr>
                    <th class="table-check am-text-left" style="width:5%">
                        <input type="checkbox" class="checkAll" checked/>
                    </th>
                    <th class="table-type am-text-left" style="width:20%">
                        表名
                    </th>
                    <th class="table-title am-text-left" style="width:10%">
                        数据量
                    </th>
                    <th class="table-set am-text-left" style="width:10%">
                        数据大小
                    </th>
                    <th class="table-set am-text-left" style="width:15%">
                        创建时间
                    </th>
                    <th class="table-set am-text-left" style="width:15%">
                        备份状态
                    </th>
                    <th class="table-set am-text-left" style="width:25%">
                        操作
                    </th>
                </tr>
            </thead>
            <tbody>
                <?php if(!empty($list)): if(is_array($list)): foreach($list as $key=>$table): ?><tr>
                            <td>
                                <input type="checkbox" value="<?php echo ($table["name"]); ?>" name="tables[]" class="ck" checked/>
                            </td>
                            <td>
                                <?php echo ($table["name"]); ?>
                            </td>
                            <td>
                                <?php echo ($table["rows"]); ?>
                            </td>
                            <td>
                                <?php echo (format_bytes($table["data_length"])); ?>
                            </td>
                            <td>
                                <?php echo ($table["create_time"]); ?>
                            </td>
                            <td class="info">
                                未备份
                            </td>
                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <a class="am-btn am-btn-default am-btn-xs am-text-secondary ajax-get no-refresh" href="<?php echo U('optimize?tables='.$table['name']);?>"><span class="am-icon-refresh"></span>优化表</a>
                                        <a class="am-btn am-btn-default am-btn-xs am-text-success ajax-get no-refresh" href="<?php echo U('repair?tables='.$table['name']);?>"><span class="am-icon-eraser"></span>修复表</a>
                                    </div>
                                </div>
                            </td>
                        </tr><?php endforeach; endif; ?>
                    <?php else: ?>
                    <td colspan="6" class="text-center">
                        暂时还没有内容! 
                    </td><?php endif; ?>
            </tbody>
        </table>
    </form>
    <!-- 分页 -->
    <ul class="am-pagination am-pagination-default am-no-layout amz-social">
        <?php echo ($_page); ?>
    </ul>

    </div>
</div>
<a class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"
  style="z-index:980;"></a>
</body>

</html>

	<!-- /主体 -->

	<!-- 底部 -->
	<!-- 底部
================================================== -->
<footer>
</footer>
<script type="text/javascript">
    (function(){
        var ThinkPHP = window.Think = {
            "ROOT"   : "", //当前网站地址
            "APP"    : "/blovex4.php?s=", //当前项目地址
            "PUBLIC" : "/Public", //项目公共目录地址
            "DEEP"   : "<?php echo C('URL_PATHINFO_DEPR');?>", //PATHINFO分割符
            "MODEL"  : ["<?php echo C('URL_MODEL');?>", "<?php echo C('URL_CASE_INSENSITIVE');?>", "<?php echo C('URL_HTML_SUFFIX');?>"],
            "VAR"    : ["<?php echo C('VAR_MODULE');?>", "<?php echo C('VAR_CONTROLLER');?>", "<?php echo C('VAR_ACTION');?>"]
        }
    })();
</script>
<!--[if lt IE 9]>
    <script src="/Public/Blovex4/js/jquery-1.8.min.js"></script>
    <script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
	<script src="/Public/Blovex4/js/polyfill/rem.min.js"></script>
	<script src="/Public/Blovex4/js/polyfill/respond.min.js"></script>
    <script src="/Public/Blovex4/js/amazeui.legacy.js"></script>
<![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
    <script type="text/javascript" src="/Public/Common/js/jquery-2.0.3.min.js">
    </script>
    <script type="text/javascript" src="/Public/Common/js/amazeui.min.js">
    </script>
<!--<![endif]-->
<script src="/Public/Common/js/jquery.datetimepicker.js" type="text/javascript">
</script>
<script src="/Public/Blovex4/js/think.js" type="text/javascript">
</script>
<script src="/Public/Blovex4/js/custom.js" type="text/javascript">
</script>
<script src="/Public/Common/js/jquery.nicescroll.js" type="text/javascript">
</script>

    <script type="text/javascript">
        (function($){
            var $form = $("#export-form"), $export = $("#export"), tables
            $optimize = $("#optimize"), $repair = $("#repair");
            
            $optimize.add($repair).click(function(){
                $.post(this.href, $form.serialize(), function(data){
                    if (data.status) {
                        updateAlert(data.info, 'alert-success');
                    }
                    else {
                        updateAlert(data.info, 'alert-error');
                    }
                    setTimeout(function(){
                        $('#top-alert').find('button').click();
                        $(that).removeClass('am-disabled').prop('am-disabled', false);
                    }, 1500);
                }, "json");
                return false;
            });
            
            $export.click(function(){
                $export.parent().children().addClass("am-disabled");
                $export.html("正在发送备份请求...");
                $.post($form.attr("action"), $form.serialize(), function(data){
                    if (data.status) {
                        tables = data.tables;
                        $export.html(data.info + "开始备份，请不要关闭本页面！");
                        backup(data.tab);
                        window.onbeforeunload = function(){
                            return "正在备份数据库，请不要关闭！"
                        }
                    }
                    else {
                        updateAlert(data.info, 'alert-error');
                        $export.parent().children().removeClass("am-disabled");
                        $export.html("立即备份");
                        setTimeout(function(){
                            $('#top-alert').find('button').click();
                            $(that).removeClass('am-disabled').prop('am-disabled', false);
                        }, 1500);
                    }
                }, "json");
                return false;
            });
            
            function backup(tab, status){
                status && showmsg(tab.id, "开始备份...(0%)");
                $.get($form.attr("action"), tab, function(data){
                    if (data.status) {
                        showmsg(tab.id, data.info);
                        
                        if (!$.isPlainObject(data.tab)) {
                            $export.parent().children().removeClass("am-disabled");
                            $export.html("备份完成，点击重新备份");
                            window.onbeforeunload = function(){
                                return null
                            }
                            return;
                        }
                        backup(data.tab, tab.id != data.tab.id);
                    }
                    else {
                        updateAlert(data.info, 'alert-error');
                        $export.parent().children().removeClass("am-disabled");
                        $export.html("立即备份");
                        setTimeout(function(){
                            $('#top-alert').find('button').click();
                            $(that).removeClass('am-disabled').prop('am-disabled', false);
                        }, 1500);
                    }
                }, "json");
                
            }
            
            function showmsg(id, msg){
                $form.find("input[value=" + tables[id] + "]").closest("tr").find(".info").html(msg);
            }
        })(jQuery);
    </script>

<!-- 用于加载js代码 -->


	<!-- /底部 -->
</body>
</html>